<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>${title}--学员页</title>
    <script src="${pageContext.servletContext.contextPath}/js/jquery-3.4.1.js"></script>
    <script>
        $(function () {
            $("input[name='name']").blur(function () {
                //异步的请求checkname的servlet
               /* $.get("${pageContext.servletContext.contextPath}/checkname?name="+this.value,function (rs) {
                    alert(rs)
                })*/
                $.ajax({
                    url:"${pageContext.servletContext.contextPath}/checkname?name="+this.value,
                    type:"GET",
                    success:function (rs) {
                        alert(rs)
                    }
                })
            })
        });
    </script>
    <%--<script>
        function checkname(obj) {
            var value = obj.value
            var xhr = new XMLHttpRequest()
            xhr.open("GET","${pageContext.servletContext.contextPath}/checkname?name="+value)
            xhr.send();
            xhr.onreadystatechange=function () {
                if(xhr.readyState == 4){
                    if(xhr.status == 200){
                        alert(xhr.responseText)
                    }
                }
            }
        }
    </script>--%>
</head>
<body>
<c:set var="btn" value="保存" scope="page"></c:set>
${title}学员表单
<form action="update" method="post">
    <c:if test="${not empty param['id']}">
      学号：  <input type="text" name="id" value="${param['id']}"><br />
        <c:set var="btn" value="修改" scope="page"></c:set>
    </c:if>
    姓名： <input type="text"  name="name" value="${student.name}" ><br />
    性别： <input type="radio" <c:if test="${student.gender eq '男'}">  checked="checked"  </c:if> name="gender" value="男">男
          <input type="radio" <c:if test="${student.gender eq '女'}">  checked="checked"  </c:if> name="gender" value="女">女<br />
    <fmt:formatDate var="isobornday" value="${student.bornday}" scope="page" pattern="yyyy-MM-dd'T'HH:mm"></fmt:formatDate>
    生日： <input type="datetime-local" name="bornday" value="${isobornday}"> <br />
    <input type="submit" value="${btn}">

</form>
</body>
</html>
